﻿function seniorCtrl($scope,$http,$timeout,applyPubNubChat) {
	window.ondragstart = function() { return false; } 
	
    $scope.chatMode=2;
	var touchFlg=false

	
	
	/* disable right click in senior Mode */
    document.oncontextmenu=RightMouseDown;

	function RightMouseDown() {
		//return false;
	}
	

	
	$(window).bind('touchstart',function(){
		
		if (!touchFlg)
		{
		touchFlg=true;
		/*return;*/
		//hide cursor from senior if touch is enabled in chrome
			$("<link/>", {
		   rel: "stylesheet",
		   type: "text/css",
		   href: "/content/css/touch.css"
		}).appendTo("head");
		
		}
		
		
	});
	

	applyPubNubChat($scope);
	var UrgentArea=function (){
		this.showConfirm=true;
		this.showErr=false;
		this.showSending=false;
		this.showOk=false;
		var parent=this;
		this.initAlertMsgs =function(){
			parent.showErr=false;
			parent.showSending=false;
			parent.showOk=false;
			parent.showConfirm=false;
		}
		this.showConfirmMsg=function(){
			parent.initAlertMsgs();
			parent.showConfirm=true;
		}
		this.showSendingMsg=function(){
			parent.initAlertMsgs();
			parent.showSending=true;
		}
		this.showOkMsg=function(){
			parent.initAlertMsgs();
			parent.showOk=true;
		}
		this.showErrMsg=function(){
			parent.initAlertMsgs();
			parent.showErr=true;
		}
		this.sendSms = function () {
			parent.showSendingMsg();
	
			
					$http({method: 'GET', url: '/saftalk/sendAlert'}).  success(function(data, status, headers, config) {
				
			
				
            	if (!data.success)
                {
				
					
					$timeout(function(){parent.showErrMsg()},1000);
				
				} else {
					
					
					$timeout(function(){parent.showOkMsg();
					
					},2000);
					$timeout(function(){$scope.selectMsgsPane();parent.showConfirmMsg();
					$scope.message.text = "שימו לב, לחצתי על כפתור ההודעה הדחופה, אנא צרו איתי קשר בהקדם!";
					$scope.publish();
					},7000);
				}
		  }).error(function(data, status, headers, config) {
					parent.showErrMsg();
		  });
		  }
			
		
	}
	
	$scope.urgentArea= new UrgentArea();
	

}
seniorCtrl.$inject = ['$scope','$http','$timeout','applyPubNubChat'];